package org.sakai.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Param;
import org.sakai.entity.Doctor;
import org.sakai.entity.dto.DoctorQueryDto;

import java.util.List;

/**
* @author Sakai
* @description 针对表【doctor(医生档案表)】的数据库操作Mapper
* @createDate 2025-06-21 11:19:12
* @Entity org.sakai.entity.Doctor
*/
@Mapper
public interface DoctorMapper {

    int deleteByPrimaryKey(String id);

    int insert(Doctor record);

    int insertSelective(Doctor record);

    Doctor selectByPrimaryKey(String id);

    int updateByPrimaryKeySelective(Doctor record);

    int updateByPrimaryKey(Doctor record);

    @Select("SELECT id from doctor order by RAND() LIMIT 1")
    String selectRandomDoctorId();

    @Select("select price from doctor where id = #{doctorId}")
    Double getPriceByDoctorId(String doctorId);

    @Select("select * from doctor limit #{pageSize} offset #{current}")
    List<Doctor> getDoctorListDetail(Long current, Long pageSize);

    @Select("select doctor_name,expertise,social_position,price,avatar " +
            "from (select id,doctor_name,expertise,social_position,price from doctor limit #{pageSize} offset #{current}) t " +
            "join user on t.id = user.id")
    List<Doctor> getDoctorListPreview(Long current, Long pageSize);

    /**
     * 查询医生列表
     * @param queryDto 查询参数
     * @return 医生列表
     */
    List<Doctor> selectDoctorList(@Param("query") DoctorQueryDto queryDto);

    /**
     * 根据ID查询医生
     * @param id 医生ID
     * @return 医生信息
     */
    Doctor selectDoctorById(@Param("id") String id);
}
